package com.aceitunaproject.server.message.processor;

import java.util.LinkedList;



import com.aceitunaproject.server.AceitunaContext;
import com.aceitunaproject.server.map.MapTile;
import com.aceitunaproject.server.player.Player;
import com.aceitunaproject.server.translator.TileTranslator;
import com.aceitunaproject.shared.message.Message;
import com.aceitunaproject.shared.message.concrete.MapAreaRefreshEvent;


/**
 * @author Federico Bergstein
 *
 * Handles the MapAreaRefreshRequest Message, sends a map refresh to the player
 */
public class MapAreaRefreshRequestProcessor implements MessageProcessor {

	
	/* (non-Javadoc)
	 * @see com.aceitunaproject.server.message.processor.MessageProcessor#processMessage(com.aceitunaproject.server.player.Player, com.aceitunaproject.shared.message.Message)
	 */
	@Override
	public void processMessage(Player player, Message message) {
		

	
			// refreshes the user map
			MapAreaRefreshEvent response = new MapAreaRefreshEvent();

			LinkedList<MapTile> list = AceitunaContext.getMapManager().getAllTiles();

			response.setAreaTiles(TileTranslator.ListToShared(list));
			player.sendObjectMessage(response);

		
	}

}
